package achi.community.irla.beans;

import achi.community.irla.database.AchievementsHandler;
import achi.community.irla.database.ModelBean;
import achi.community.irla.entities.Achievements;
import java.io.Serializable;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import javax.faces.bean.*;

/**
 * <p>The TextFieldsBean class is the backing bean for the Text Entry
 * demonstration. It is used to store the values of the input fields.</p>
 */

@ManagedBean
@RequestScoped
public class SearchBackBean implements Serializable{
    /**
     * The different kinds of text input fields.
     */

    @ManagedProperty(value = "#{modelBean}")
    ModelBean modelBean;
    
    @ManagedProperty(value = "#{achievementsHandler}")
    AchievementsHandler achiHandler;
    
    private Achievements achi;
    private String value;
    //private List<Achievements> usersTarget;
    private String usersTarget="aa";
    private HashMap<String,Achievements> test;

    public void setTest(HashMap<String, Achievements> test) {
        this.test = test;
    }

    public HashMap getTest() {
        test = achiHandler.getTargetMap();
       /**
        if(achiHandler == null)
            System.out.println("achiHandler == null @ SearchBackBean");
        else
            System.out.println("achiHandler == "+achiHandler);
        test = new HashMap<String,Achievements>();
        test.put("one",new Achievements("titleswe", "title2", "descsv", "descen", "ccat", "sssubcat", "achi1.jpg", 0));
        test.put("two",new Achievements("titleswe1", "title21", "descsv1", "descen1", "ccat1", "sssubcat1", "basketball.png", 0));
        test.put("three",new Achievements("titleswe2", "title22", "descsv2", "descen2", "ccat2", "sssubcat2", "golf.jpg", 0));
        */
        
        return test;
    }


    public AchievementsHandler getAchiHandler() {
        return achiHandler;
    }

    public void setAchiHandler(AchievementsHandler achiHandler) {
        this.achiHandler = achiHandler;
    }

    public void setUsersTarget(String usersTarget) {
        this.usersTarget = usersTarget;
    }

   // public void setUsersTarget(List<Achievements> usersTarget) {
   //     this.usersTarget = usersTarget;
  //  }

    public ModelBean getModelBean() {
        return modelBean;
    }

    public void setModelBean(ModelBean modelBean) {
        this.modelBean = modelBean;
    }

    public Achievements getAchi() {
        return achi;
    }

    public void setAchi(Achievements a) {
        System.out.println("aaaaa:"+a.getTitle_sv());
        this.achi = a;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }

//    public List<Achievements> getUsersTarget(){
//        return modelBean.getUsersTarget();
//    }
  
    public String getUsersTarget(){
        //List<Achievements> list = modelBean.getUsersTarget();
        String tachi = "test :O";//list.get(nr);
        return usersTarget;
    }
}